<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">

    <title>系统配置</title>
    <link rel="stylesheet" th:href="@{/layui/layui/css/layui.css}">
   
</head>
<body>
<div class="layui-main">
    <br />
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
            <li class="layui-this" lay-id="111">首页设置</li>
            <li lay-id="222">百度统计</li>
            <li lay-id="333">上传配置</li>

        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">首页公告</label>
                        <div class="layui-input-block">
                            <input id="notice" type="text" name="title" autocomplete="off" placeholder="首页公告" class="layui-input"
                                   th:value="${config.getNotice()}"/>
                            <span style="color: #DAA5A6;">欲想显示多个公告请用 | 分开</span>
                        </div>
                    </div>
                    <hr />
                    <br/>
                <div class="layui-form-item">
                    <label class="layui-form-label">网站标题</label>
                    <div class="layui-input-block">
                        <input id="webname" type="text" name="title" autocomplete="off" placeholder="网站标题" class="layui-input"
                               th:value="${config.getWebname()}"/>
                    </div>
                </div>
                <br />
                    <div class="layui-form-item">
                        <label class="layui-form-label">站点域名</label>
                        <div class="layui-input-block">
                            <input id="domain" type="text" name="title" autocomplete="off" placeholder="站点域名" class="layui-input"
                                   th:value="${config.getDomain()}"/><span style="color: #DAA5A6;">填写访问本站的域名或IP,否则开启邮箱激活不能正常使用。需带有http://或https://</span>
                        </div>
                    </div>
                    <br />
                <div class="layui-form-item">
                    <label class="layui-form-label">站点说明</label>
                    <div class="layui-input-block">
                        <input id="explain" type="text" name="title" autocomplete="off" placeholder="站点说明" class="layui-input"
                               th:value="${config.getExplain()}"/>
                    </div>
                </div>
<!--                <br />-->
<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label">页面LOGO</label>-->
<!--                    <div class="layui-input-block">-->
<!--                        <input id="logos" type="text" name="title" autocomplete="off" placeholder="页面LOGO" class="layui-input"-->
<!--                               th:value="${config.getLogos()}"/><span style="color: #DAA5A6;">图片推荐大小：242px*33px</span>-->
<!--                    </div>-->
<!--                </div>-->
                    <br />
<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label">底部版权</label>-->
<!--                    <div class="layui-input-block">-->
<!--                        <input id="footed" type="text" name="title" autocomplete="off" placeholder="底部版权" class="layui-input"-->
<!--                               th:value="${config.getFooted()}"/>-->
<!--                    </div>-->
<!--                </div>-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">首页背景一</label>
                        <div class="layui-input-block">
                            <input id="background1" type="text" name="title" autocomplete="off" placeholder="首页背景图" class="layui-input"
                                   th:value="${config.getBackground1()}"/>
                        </div>
                    </div>
                    <br />
                    <div class="layui-form-item">
                        <label class="layui-form-label">首页背景二</label>
                        <div class="layui-input-block">
                            <input id="background2" type="text" name="title" autocomplete="off" placeholder="上传页面背景图" class="layui-input"
                                   th:value="${config.getBackground2()}"/>
                        </div>
                    </div>
                    <br />
<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label">友情链接</label>-->
<!--                    <div class="layui-input-block">-->
<!--                        <textarea id="links" name="links" placeholder="请输入内容" class="layui-textarea" th:text="${config.getLinks()}"></textarea>-->
<!--                        <span style="color: #DAA5A6;">友链格式（否则会显示异常）：<xmp><li><a src="地址">网站名</a></li></xmp></span>-->
<!--                    </div>-->
<!--                </div>-->


                </form>
                <a class="layui-btn" lay-filter="demo2" onclick="updateconfig()">保存</a>
            </div>
            <div class="layui-tab-item">
                <form class="layui-form layui-form-pane" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">统计JS代码</label>
                    <div class="layui-input-block">
                        <textarea id="baidu" name="baidu" placeholder="请输入统计JS代码" class="layui-textarea" th:text="${config.getBaidu()}"></textarea>
                        <span style="color: #DAA5A6;"><xmp>添加网站统计的JS代码，不需要要添加<script>标签</script></xmp></span>
                    </div>
                    <a class="layui-btn" lay-filter="demo2" onclick="updatebaidu()">保存</a>
                </div>
                </form>
            </div>
<!--分组3-->
            <div class="layui-tab-item">
                <h3>游客上传配置</h3>
                <hr />
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 100px;">单个文件大小(M)</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input id="filesizetourists" th:value="${updateConfig.getFilesizetourists()}"  type="text" name="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 50px;">
                    <label class="layui-form-label" style="width: 100px;">单次上传个数</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input id="imgcounttourists" th:value="${updateConfig.getImgcounttourists()}" type="text" name="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <br />
                <h3 style="margin-top: 50px;">会员上传配置</h3>
                <hr />
                <div class="layui-inline" >
                    <label class="layui-form-label" style="width: 100px;">单个文件大小(M)</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input id="filesizeuser" th:value="${updateConfig.getFilesizeuser()}" type="text" name="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 50px;">
                    <label class="layui-form-label" style="width: 100px;">单次上传个数</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input id="imgcountuser" th:value="${updateConfig.getImgcountuser()}" type="text" name="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <br />
                <h3 style="margin-top: 50px;">支持文件配置</h3>
                <hr />
                <div class="layui-form-item">
                    <label class="layui-form-label">文件类型</label>
                    <div class="layui-input-block">
                        <input id="suffix" th:value="${updateConfig.getSuffix()}" type="text" name="title" required  lay-verify="required" placeholder="配置可上传的文件类型" autocomplete="off" class="layui-input">
                        <span style="color: #DAA5A6;">配个类型用“ , ”隔开</span>
                    </div>
                </div>

                <a class="layui-btn" lay-filter="demo2" onclick="scconfig()">保存</a>
            </div>

        </div>
    </div>
</div>


<script th:src="@{/static/js/jquery-3.4.1.min.js}" type="text/javascript"></script>
<script th:src="@{/layui/layui/layui.js}"></script>

    <script type="text/javascript">
        layui.use(['table','element'], function(){
            var table = layui.table;
            var element = layui.element;
            });
        function updateconfig() {
                var webname = $("#webname").val();
                var explain = $("#explain").val();
                var logos = $("#logos").val();
                var footed = $("#footed").val();
                var links = $("#links").val();
                var notice = $("#notice").val();
                var domain = $("#domain").val();
                var background1 = $("#background1").val();
                var background2 = $("#background2").val();
                if (webname != "" && domain!="" ) {
                    $.ajax({
                        type: "POST",
                        url: "/admin/root/updateconfig",
                        dataType: "json",
                        data: {webname: webname, explain: explain, logos: logos,footed:footed,links:links,notice:notice,domain:domain,background1:background1,background2:background2},
                        success: function (data) {
                            var vals = Number(data);
                            if (vals > 0) {
                                layer.msg("保存成功", {icon: 1});
                                //window.location.reload();
                            } else {
                                layer.msg("保存失败，请尝试刷新页面后操作", {icon: 2});
                            }
                        }
                    });
                } else {
                    layer.msg("网站名称或站点域名均不能为空", {icon: 2});
                }
        }
        function updatebaidu() {
            var baidu = $("#baidu").val();
            $.ajax({
                type: "POST",
                url: "/admin/root/updateconfig",
                dataType: "json",
                data: {baidu: baidu},
                success: function (data) {
                    var vals = Number(data);
                    if (vals > 0) {
                        layer.msg("保存成功", {icon: 1});
                        //window.location.reload();
                    } else {
                        layer.msg("保存失败，请尝试刷新页面后操作", {icon: 2});
                    }
                }
            });
        }
        function scconfig() {
            var filesizetourists = $("#filesizetourists").val();
            var filesizeuser = $("#filesizeuser").val();
            var imgcounttourists = $("#imgcounttourists").val();
            var imgcountuser = $("#imgcountuser").val();
            var suffix = $("#suffix").val();
            if(filesizetourists!=""&&filesizeuser!=""&&imgcounttourists!=""&&imgcountuser!=""&&suffix!=""){
                $.ajax({
                    type: "POST",
                    url: "/admin/root/scconfig",
                    dataType: "json",
                    data: {filesizetourists: filesizetourists,filesizeuser:filesizeuser,imgcounttourists:imgcounttourists,imgcountuser:imgcountuser,suffix:suffix},
                    success: function (data) {
                        var vals = Number(data);
                        if (vals > 0) {
                            layer.msg("保存成功", {icon: 1});
                            //window.location.reload();
                        } else {
                            layer.msg("保存失败，请尝试刷新页面后操作", {icon: 2});
                        }
                    }
                });
            }else{
                layer.msg("各项内容不能为空", {icon: 2});
            }

        }


    </script>
</body>
</html>